<template>
  <!-- 我----设置 -->
  <div class="Setting">
    <van-nav-bar
        title="设置"
        left-text=""
        left-arrow
        @click-left="onClickLeft"
    />
    <van-cell title="消息设置" is-link to="/InfoSetting"/>
    <van-cell title="账户设置" is-link to="/MyMessageSetting"/>
    <van-cell title="版本更新" is-link to="/MyVersion"/>
    <van-cell is-link @click="showPopup">清除缓存</van-cell>
    <van-cell title="分享APP" is-link to="/ShareApp"/>
    <div class="center">
      <van-button type="info" @click="LogOutBtn">退出登录</van-button>
    </div>
  </div>
</template>

<script>
import {Toast} from "vant";
import {mapGetters, mapActions} from 'vuex'

export default {
  name: "Setting",
  data() {
    return {
      show: false,
    };
  },
  mounted() {
  },
  methods: {
    ...mapActions(['outLogin']),
    //退出登录
    LogOutBtn() {
      this.$dialog
          .confirm({
            title: "确认退出登录",
            message: "请确认是否退出核桃仁APP,退出后无法接收相关信息",
          })
          .then(() => {
            this.outLogin();
            localStorage.clear();
            Toast.success('退出登录');
            this.$router.push('/');
          })
          .catch(() => {
            // on cancel
          });
    },
    showPopup() {
      this.$dialog
          .confirm({
            title: "清除缓存",
            message: "请确认是否清除app缓存内容？",
          })
          .then(() => {
            // on confirm
          })
          .catch(() => {
            // on cancel
          });
    },
    onClickLeft() {
      this.$router.push("/my");
    },
  },
};
</script>

<style scoped lang="less">
.center {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
  button{
    border-radius: 5px ;
  }
}
</style>
